

import datastructurelike.TreeNode;

import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Like
 * Date: 2021-07-13
 * Time: 17:06
 */

public class demo {

    private static int[][] ans;
    ArrayList<Integer> pre= new ArrayList<>();
    ArrayList<Integer> in= new ArrayList<>();
    ArrayList<Integer> post= new ArrayList<>();

    public int[][] threeOrders(TreeNode root){
        preOrder(root);
        inOrder(root);
        postOrder(root);

        return ans;
    }

    private void postOrder(TreeNode root) {
       if (root==null) {
           return;
       }
       postOrder(root.left);
       postOrder(root.right);
       post.add(root.val);
    }

    private void preOrder(TreeNode root) {
        if (root==null) {
            return;
        }
        pre.add(root.val);
        postOrder(root.left);
        postOrder(root.right);

    }

    private void inOrder(TreeNode root) {
        if (root==null) {
            return;
        }
        postOrder(root.left);
        in.add(root.val);
        postOrder(root.right);

    }

}
